﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Entity;
using BLL;

namespace BookStore.Controllers
{
    public class RegisterController : Controller
    {
        //
        // GET: /Register/
        //注册
        public ActionResult Index()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Index(UserInfo us, string UserPwd2)
        {
            if (us.UserPwd == UserPwd2)
            {
                if (T_BLogin.LogCheck(us))
                {
                    if (T_BLogin.Registered(us))
                    {
                        return RedirectToAction("Login", "login");
                    }
                    else
                    {
                        return Content("<script>alert('注册失败！');history.go(-1);;</script>");
                    }
                }
                else
                {
                    return Content("<script>alert('用户名已存在！');history.go(-1);;</script>");
                }
            }
            else
            {
                return Content("<script>alert('两次密码不一致！');history.go(-1);;</script>");
            }
        }

    }
}
